DataSource for Entity Framework in WPF
C1.LiveLinq Namespace / LiveViewExtensions Class / LiveAverage Method / LiveAverage<TSource>(View<TSource>,Expression<Func<TSource,Int64>>) Method
The type of the elements of source.
A view containing the values to calculate the average of.
A transform function to apply to each element.

In This Topic
    LiveAverage<TSource>(View<TSource>,Expression<Func<TSource,Int64>>) Method
    In This Topic
    Computes the average of a view of System.Int64 values that are obtained by invoking a transform function on each element of the source view.
    Syntax
    'Declaration
     
    Public Overloads Shared Function LiveAverage(Of TSource)( _
       ByVal source As View(Of TSource), _
       ByVal selector As Expression(Of Func(Of TSource,Long)) _
    ) As AggregationView(Of TSource,Double)

    Parameters

    source
    A view containing the values to calculate the average of.
    selector
    A transform function to apply to each element.

    Type Parameters

    TSource
    The type of the elements of source.

    Return Value

    A view representing the average of the values.
    Remarks

    If the source is empty, an System.InvalidOperationException is thrown.

    It is possible to use standard LINQ query operator Average instead of LiveAverage. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Average will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAverage will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.

    See Also